
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Syrinx.Gui.AspNet
{
	[ToolboxData("<{0}:RichEditSupport runat=server></{0}:RichEditSupport>")]
	public class RichEditSupport : WebControl
	{
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			Page.ClientScript.RegisterClientScriptBlock(typeof(String), "RichEditSupport",
			@"
    <script>
    var curName = "";
    
    function highlightNow(e)
    {
        curName = this.id;
        this.OldEvent(e);
    }
    
    function editCommand(cmdType)
    {
        if(curName != '') FTB_API[curName].ExecuteCommand(cmdType);
    }
    
    function hookup()
    {
        try
        {
          var el = FTB_FreeTextBox;
          if(el != null)
          {
            FTB_FreeTextBox.prototype.OldEvent = FTB_FreeTextBox.prototype.Event;
            FTB_FreeTextBox.prototype.Event = highlightNow;            
          }
          else
            setTimeout('hookup()',200);
         }
        catch(e)
        {
            setTimeout('hookup()', 200); 
        }
    }

	setTimeout('hookup()', 200);    
    </script>
			");
		}

		protected override void RenderContents(HtmlTextWriter output)
		{
		}
	}
}
